package com.wei.model;


import lombok.Data;

@Data
public class Extent {

	private double minX;
	private double minY;
	private double maxX;
	private double maxY;
	
	public Extent(double minX, double minY, double maxX, double maxY) {
		super();
		this.minX = minX;
		this.minY = minY;
		this.maxX = maxX;
		this.maxY = maxY;
	}
	
	public Extent() {
		super();
	}
	
	public Extent(Coordinate leftBottom, Coordinate topRight)
    {
        if (leftBottom != null && topRight != null)
        {
            this.minX = leftBottom.getX();
            this.minY = leftBottom.getY();
            this.maxX = topRight.getX();
            this.maxY = topRight.getY();
        }
    }
	
	public Extent(double[] coord) {
		this.minX = coord[0];
		this.minY = coord[1];
		this.maxX = coord[2];
		this.maxY = coord[3];
	}
			
	public Coordinate getLeftBottom()
    {
        return new Coordinate(minX, minY);
    }

    public Coordinate getTopRight()
    {
        return new Coordinate(maxX, maxY);
    }

    public Coordinate getTopLeft()
    {
        return new Coordinate(minX, maxY);
    }

    public Coordinate getRightBottom()
    {
        return new Coordinate(maxX, minY);
    }
    
    public String toString() {
    	return String.format("minX:%s,minY:%s,maxX:%s,maxY:%s",this.minX, this.minY, this.maxX, this.maxY);
    }
}
